package cn.com.zcode.exam.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;

import cn.com.zcode.attchment.model.Attachment;
import cn.com.zcode.core.model.BaseModelSupport;
import cn.com.zcode.dic.jstl.DictionaryUtil;

public class Question extends BaseModelSupport {
	private static final long serialVersionUID = 1L;
	private Integer no;
	private String ptype;
	private String ptypeName;
	private String chapter;
	private String chapterName;
	private String summary;
	private String analysis;
	private String answer;
	private Integer orderIndex = 0;
	private String language;
	private Paper paper;
	private String primaryId;
	private Wrong wrong;
	private Answer answerInfo;
	private List<Option> options= new ArrayList<Option>();;
	private List<Question> accessorys = new ArrayList<Question>();
	private List<Attachment> attachment;

	public Question(Question question, Wrong wrong) {
		super();
		BeanUtils.copyProperties(question, this);
		this.wrong = wrong;
	}

	public Paper getPaper() {
		return paper;
	}

	public void setPaper(Paper paper) {
		this.paper = paper;
	}

	private Map<String, Option> mapopts = new HashMap<String, Option>();

	public Question() {
		super();
	}

	public Integer getNo() {
		return no;
	}

	public void setNo(Integer no) {
		this.no = no;
	}

	public String getAnalysis() {
		return analysis;
	}

	public void setAnalysis(String analysis) {
		this.analysis = analysis;
	}

	public String getAnswer() {
		return answer;
	}

	public void setAnswer(String answer) {
		this.answer = answer;
	}

	public void addOption(Option option) {
		this.options.add(option);
		this.mapopts.put(option.getNo(), option);
	}

	public Option getOption(String no) {
		return this.mapopts.get(no);
	}

	public boolean hasOptions() {

		return !this.options.isEmpty();
	}

	public String getChapter() {
		return chapter;
	}

	public void setChapter(String chapter) {
		this.chapter = chapter;
	}

	public String getPtype() {
		return ptype;
	}

	public void setPtype(String ptype) {
		this.ptype = ptype;
	}

	public Wrong getWrong() {
		return wrong;
	}

	public void setWrong(Wrong wrong) {
		this.wrong = wrong;
	}

	public List<Option> getOptions() {
		return options;
	}

	public void setOptions(List<Option> options) {
		this.options = options;
	}

	public List<Attachment> getAttachment() {
		return attachment;
	}

	public void setAttachment(List<Attachment> attachment) {
		this.attachment = attachment;
	}

	public void setAccessorys(List<Question> accessorys) {
		this.accessorys = accessorys;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public Integer getOrderIndex() {
		return orderIndex;
	}

	public void setOrderIndex(Integer orderIndex) {
		this.orderIndex = orderIndex;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public List<Question> getAccessorys() {
		return accessorys;
	}

	public String getPtypeName() {
		this.ptypeName = DictionaryUtil.title(this.ptype);
		return this.ptypeName;
	}

	public String getChapterName() {
		this.chapterName = DictionaryUtil.title(this.chapter);
		return chapterName;
	}

	public String getPrimaryId() {
		return primaryId;
	}

	public void setPrimaryId(String primaryId) {
		this.primaryId = primaryId;
	}

	public Answer getAnswerInfo() {
		return answerInfo;
	}

	public void setAnswerInfo(Answer answerInfo) {
		this.answerInfo = answerInfo;
	}

 
}
